﻿        public class C读写
        {
            //函数名：LoadFileToArrayList(已完成)
            //简  述：载入文件到ArrayList
            //返回值：ArrayList
            //参数一：string，即要载入内存的文件路径
            //注  释：
            //注  意：
            public static ArrayList LoadFileToArrayList(string LoadFromHere)
            {
                Encoding ed = CBase.C主文件类.C获取.C文件编码.GetEncodingOfFile(LoadFromHere);

                ArrayList ReturnArrayList = new ArrayList();
                try
                {
                    StreamReader LoadFrom = new StreamReader(@LoadFromHere.Trim(), ed);
                    //LoadFrom = File.OpenText(@LoadFromHere.Trim());

                    while (LoadFrom.Peek() != -1)
                    {
                        ReturnArrayList.Add(LoadFrom.ReadLine());
                    }
                    LoadFrom.Close();
                }
                catch
                {
                    Console.WriteLine("载入文件" + @LoadFromHere + "失败");
                    System.Console.ReadLine();
                    ReturnArrayList.Clear();
                }

               

                return ReturnArrayList;
            }

            //函数名：LoadTenToArrayList(已完成)
            //简  述：载入文件中前33个数据到列表
            //返回值：ArrayList
            //参数一：string，即要载入内存的文件路径
            //注  释：
            //注  意：
            public static ArrayList LoadPartFileToArrayList(string LoadFromHere)
            {
                ArrayList ReturnArrayList = new ArrayList();
                StreamReader LoadFrom;

                try
                {
                    LoadFrom = File.OpenText(LoadFromHere.Trim());
                }
                catch
                {
                    Console.WriteLine("载入文件" + @LoadFromHere + "失败");
                    System.Console.ReadLine();
                    return ReturnArrayList;
                }
                int i = 0;
                while (LoadFrom.Peek() != -1)
                {
                    i = i + 1;
                    if (i < 34)
                    {
                        ReturnArrayList.Add(LoadFrom.ReadLine());
                    }
                    else
                    {
                        break;
                    }
                }

                LoadFrom.Close();

                return ReturnArrayList;
            }

            //函数名：WriteToFile(已完成)
            //简  述：将ArrayList写入文件
            //返回值：bool
            //参数一：ArrayList，要写入
            //参数二：string，到这儿
            //注  释：
            //注  意：        
            public static bool WriteToFile(ArrayList WaitWrite, string WriteTo)
            {
                StreamWriter MyWriteTo;
                try
                {
                    MyWriteTo = File.CreateText(WriteTo.Trim());
                }
                catch
                {
                    return false;
                }

                foreach (string curstr in WaitWrite)
                {
                    MyWriteTo.WriteLine(curstr);
                }

                MyWriteTo.Close();
                return true;

            }

            //函数名：WriteToFile(已完成)
            //简  述：将ArrayList写入文件
            //返回值：bool
            //参数一：HashTable，要写入
            //参数二：string，到这儿
            //注  释：
            //注  意：        
            public static bool WriteToFile(Hashtable WaitWrite, string WriteTo)
            {
                StreamWriter MyWriteTo;
                try
                {
                    MyWriteTo = File.CreateText(WriteTo.Trim());
                }
                catch
                {
                    return false;
                }

                CBase.C主框架类.C字符串类型分隔符 fgf = new C主框架类.C字符串类型分隔符();

                foreach (DictionaryEntry  de in WaitWrite)
                {
                    MyWriteTo.WriteLine(de.Key.ToString() + fgf.A + de.Value.ToString());
                }

                MyWriteTo.Close();
                return true;

            }

            //函数名：WriteToFile(已完成)
            //简  述：将ArrayList写入文件
            //返回值：bool
            //参数一：ArrayList，要写入
            //参数二：string，到这儿
            //注  释：
            //注  意：        
            public static bool WriteToFile(string WaitWrite, string WriteTo)
            {
                StreamWriter MyWriteTo;
                try
                {
                    MyWriteTo = File.CreateText(WriteTo.Trim());
                }
                catch
                {
                    return false;
                }

                MyWriteTo.WriteLine(WaitWrite);


                MyWriteTo.Close();
                return true;

            }

            //函数名：WriteToFile(已完成)
            //简  述：将Dictionary<string, string>写入文件
            //返回值：bool
            //参数一：ArrayList，要写入
            //参数二：string，到这儿
            //注  释：
            //注  意：结果以ギ为分隔符
            public static bool WriteToFile(Dictionary<string, string> WaitWrite, string WriteTo)
            {
                C主框架类.C字符串类型分隔符 splitBy = new C主框架类.C字符串类型分隔符();
                StreamWriter MyWriteTo;
                try
                {
                    MyWriteTo = File.CreateText(WriteTo.Trim());
                }
                catch
                {
                    return false;
                }

                foreach (KeyValuePair<string, string> kvp in WaitWrite)
                {
                    MyWriteTo.WriteLine(kvp.Key + splitBy.A + kvp.Value);
                }

                MyWriteTo.Close();
                return true;
            }

            //函数名：WriteToFile(已完成)
            //简  述：将Dictionary<string, int>写入文件
            //返回值：bool
            //参数一：ArrayList，要写入
            //参数二：string，到这儿
            //注  释：
            //注  意：结果以ギ为分隔符
            public static bool WriteToFile(Dictionary<string, int> WaitWrite, string WriteTo)
            {
                C主框架类.C字符类型分隔符类 splitBy = new C主框架类.C字符类型分隔符类();

                StreamWriter MyWriteTo;
                try
                {
                    MyWriteTo = File.CreateText(WriteTo.Trim());
                }
                catch
                {
                    return false;
                }

                foreach (KeyValuePair<string, int> kvp in WaitWrite)
                {
                    MyWriteTo.WriteLine(kvp.Key + splitBy.A + kvp.Value.ToString());
                }

                MyWriteTo.Close();
                return true;
            }

            //函数名：WriteToFile(已完成)
            //简  述：将Dictionary<string, double>写入文件
            //返回值：bool
            //参数一：ArrayList，要写入
            //参数二：string，到这儿
            //注  释：
            //注  意：结果以ギ为分隔符
}